package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.UserBackService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.vo.request.AddTechnicianBackVo;
import com.rm.zeyou.vo.response.SelectTechnicianBackResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 用户银行卡表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Api(tags = "用户银行卡相关")
@RestController
@RequestMapping("/api/userBack")
public class UserBackController {
    @Resource
    private UserBackService userBackService;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation("用户添加银行卡")
    @PostMapping("addUserBack")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<Integer> addUserBack(@RequestBody AddTechnicianBackVo addVo) {
        User user = loginUtil.getUser();
        return userBackService.addUserBack(user.getId(), addVo);
    }

    @ApiOperation("查询用户银行卡列表")
    @GetMapping("selectUserBackList")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<SelectTechnicianBackResponseVo> selectUserBackList() {
        User user = loginUtil.getUser();
        return userBackService.selectUserBackList(user.getId());
    }
}
